<?php class Moons { 

    /***
     * DB Fields: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id;

    /***
     * DB Fields: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $name;

    /***
     * DB Fields: size
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $size;

    /***
     * DB Fields: sizeBuilt
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $sizeBuilt;

    /***
     * DB Fields: position
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $position;

    /***
     * DB Fields: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $planetId;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id
     **/
    function get_id( ) {
        // returns the value of id
        return $this->id;
    }


    /***
     * Get value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result name
     **/
    function get_name( ) {
        // returns the value of name
        return $this->name;
    }


    /***
     * Get value for field: size
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result size
     **/
    function get_size( ) {
        // returns the value of size
        return $this->size;
    }


    /***
     * Get value for field: sizeBuilt
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result sizeBuilt
     **/
    function get_sizeBuilt( ) {
        // returns the value of sizeBuilt
        return $this->sizeBuilt;
    }


    /***
     * Get value for field: position
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result position
     **/
    function get_position( ) {
        // returns the value of position
        return $this->position;
    }


    /***
     * Get value for field: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result planetId
     **/
    function get_planetId( ) {
        // returns the value of planetId
        return $this->planetId;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function set_id( $id ) {
        // sets the value of id
        $this->id = $id;
    }

    /***
     * Set value for field: name
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param name
     * @result void
     **/
    function set_name( $name ) {
        // sets the value of name
        $this->name = $name;
    }

    /***
     * Set value for field: size
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param size
     * @result void
     **/
    function set_size( $size ) {
        // sets the value of size
        $this->size = $size;
    }

    /***
     * Set value for field: sizeBuilt
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param sizeBuilt
     * @result void
     **/
    function set_sizeBuilt( $sizeBuilt ) {
        // sets the value of sizeBuilt
        $this->sizeBuilt = $sizeBuilt;
    }

    /***
     * Set value for field: position
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param position
     * @result void
     **/
    function set_position( $position ) {
        // sets the value of position
        $this->position = $position;
    }

    /***
     * Set value for field: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param planetId
     * @result void
     **/
    function set_planetId( $planetId ) {
        // sets the value of planetId
        $this->planetId = $planetId;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: moons
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param name
     * @param size
     * @param sizeBuilt
     * @param position
     * @param planetId
     * @result void
     **/
    function createnew_moons( $id, $name, $size, $sizeBuilt, $position, $planetId ) {

        // items to be inserted in the database 
        $_obj = array($id,
                      $name,
                      $size,
                      $sizeBuilt,
                      $position,
                      $planetId); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("moons", $_obj);
    }

    /***
     * Retrived an existing record: moons
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result new Moons
     **/
    function get_moons( $id ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM moons WHERE id = '$id'");

        $__moonsObj = new moons();
        // return the retrived from the database

        // create a new object
        $__obj = new Moons();
        $__obj->set_id($_resultSet[0]['id']);
        $__obj->set_name($_resultSet[0]['name']);
        $__obj->set_size($_resultSet[0]['size']);
        $__obj->set_sizeBuilt($_resultSet[0]['sizeBuilt']);
        $__obj->set_position($_resultSet[0]['position']);
        $__obj->set_planetId($_resultSet[0]['planetId']);


        return $__obj;
    }

    /***
     * Update an existing record: moons
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_moons( $id, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("moons", "id = '$id'");
    }

    /***
     * Delete an existing record: moons
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function delete_moons( $id ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("moons", "id = '$id'");
    }

    /***
     * Retrived list of objects base on a given parameters: moons
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Moons
     **/
    function list_moons( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM moons WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM moons";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Moons();

            $__newObj->set_id($__rs['id']);
            $__newObj->set_name($__rs['name']);
            $__newObj->set_size($__rs['size']);
            $__newObj->set_sizeBuilt($__rs['sizeBuilt']);
            $__newObj->set_position($__rs['position']);
            $__newObj->set_planetId($__rs['planetId']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>